package newPan3d.content.glass
{
	import _Pan3D.display3D.Display3DSprite;
	import _Pan3D.program.Program3DManager;
	import _Pan3D.program.shaders.GlassShader;
	
	import _me.Scene_data;
	
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display3D.Context3D;
	import flash.display3D.Program3D;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	import robotleMvc.ui.glass.GlassDisplay3DContainer;
	
	public class GlassLevel
	{
		private var _display3DContainer:GlassDisplay3DContainer;
		private var _context3D:Context3D;
		private var _glassDisplay3DSprite:NewGlassDisplay3DSprite;
		
		public function GlassLevel()
		{
			_display3DContainer=new GlassDisplay3DContainer();
			_context3D=Scene_data.context3D;
			initGlass()
			
		}
		private function initGlass():void
		{
			_glassDisplay3DSprite=new NewGlassDisplay3DSprite(_context3D);
			_glassDisplay3DSprite.url="cao03_yizhan"
			_glassDisplay3DSprite.x=0
			_glassDisplay3DSprite.y=0
			_glassDisplay3DSprite.z=0
			_glassDisplay3DSprite.scale=1;
			_display3DContainer.addChild(_glassDisplay3DSprite);
			var treeShaderProgram3d:Program3D=Program3DManager.getInstance().getProgram(GlassShader.GLASS_SHADER);
			_display3DContainer.setProgram3D(treeShaderProgram3d);
			
		
			_glassDisplay3DSprite.addEventListener(Display3DSprite.LOAD_COMPLETE,_loadComplete)
		
		
		}
		
		protected function _loadComplete(event:Event):void
		{
			loadGlassPic();
		}
		public function upData():void
		{
			_display3DContainer.update();
		}
		public function loadGlassPic():void
		{
			var _picloader:Loader=new Loader();
			var _picloaderURL:URLRequest=new URLRequest(Scene_data.fileRoot + "ground/glassInfoPic.jpg");
			_picloader.load(_picloaderURL);
			_picloader.contentLoaderInfo.addEventListener(Event.COMPLETE, _load_pic_ok);
		}
		private function _load_pic_ok(event:Event):void
		{
			var loader:Loader=Loader(event.target.loader);
			var image:Bitmap=Bitmap(loader.content);
			_glassDisplay3DSprite.setGlassInfoBitmapdata(image.bitmapData);
		}
	}
}